<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./StakeholderTemplate.xhtml">
    <ui:define name="begin">
        <ui:insert name="beginMeal">
            
        </ui:insert>
        
    </ui:define>
    <ui:define name="contentInsert"> 
            <ui:insert name="contentMeal">                
            </ui:insert>
             <h:form id="formPrice" style="position: relative; float:left; width: 500px;" >
            <p:panel header="Price Control" id="panelPrice" style="height: 350px;" rendered="#{mealManagerBean.selectedProduct != null}">
                <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                    </f:facet>

                    <f:facet name="complete">
                        <h:outputText value="" />
                    </f:facet>
                </p:ajaxStatus>
                <p:messages />

                <h:panelGrid columns="2" id="gridPrice">
                    <h:outputLabel value="Price : *" for="txt_title"></h:outputLabel>
                    <p:inputText id="txt_title" 
                                 value="#{mealManagerBean.priceControl.price}" required="true"/>

                    <h:outputLabel value="Type:"/>
                    <h:selectOneMenu id="city" value="#{mealManagerBean.priceControl.type}">  
                        <f:selectItems value="#{mealManagerBean.dayOfWeek}" />  
                        <p:ajax update="calendar" />  
                    </h:selectOneMenu>  

                    <h:outputLabel value="Specific Date :"/>
                    <p:calendar id="calendar" value="#{mealManagerBean.priceControl.specificDate}" disabled="#{mealManagerBean.priceControl.type!=8}"/>


                    <h:outputLabel value="Start Hour: *" for="startHour"/>
                    <h:selectOneMenu id="startHour" value="#{mealManagerBean.priceControl.startTime}">  
                        <f:selectItems value="#{mealManagerBean.timeOfDay}" />  
                    </h:selectOneMenu>  

                    <h:outputLabel value="End Hour: *" for="endHour"/>
                    <h:selectOneMenu id="endHour" value="#{mealManagerBean.priceControl.endTime}">  
                        <f:selectItems value="#{mealManagerBean.timeOfDay}" />  
                    </h:selectOneMenu>  

                    <p:commandButton id="reset" value="Reset" type="reset"/>
                    <p:commandButton id="add" value="Add" update="formPriceControl"
                                     actionListener="#{mealManagerBean.addPriceControl}" ajax="true" />
                </h:panelGrid>       
            </p:panel>
        </h:form>

        <h:form id="formAvail" style="position: relative; float:left; width: 300px;">
            <p:panel id="panelAvail" header="Edit product Availability" rendered="#{mealManagerBean.selectedProduct != null}">
                <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value="" />
                    </f:facet>
                </p:ajaxStatus>
                <p:messages />
                <h:panelGrid columns="3" cellpadding="10">
                    <p:dataTable var="avail" value="#{mealManagerBean.listOfAvail}" selection="#{mealManagerBean.selectedAvail}" rows="10">
                        <p:column selectionMode="multiple" />

                        <p:column headerText="Name">
                            <h:outputText value="#{avail.description}" />
                        </p:column>

                    </p:dataTable>

                </h:panelGrid>
                <p:commandButton id="btn" value="Change Avail" update="panelAvail" actionListener="#{mealManagerBean.editAvail}" ajax="true" />
            </p:panel>
        </h:form>
        <h:form id="formPriceControl" style="position: relative; float:left; width: 500px;">

            <p:outputPanel id="books" rendered="#{mealManagerBean.selectedProduct != null}">
                <p:dataTable value="#{mealManagerBean.listOfPriceControl}" var="list" 
                             rowEditListener="#{mealManagerBean.editPriceControl}" onRowEditUpdate ="panelPrice" id="priceTable">

                    <p:column headerText="Price" style="width:100px">  
                        <p:cellEditor>  
                            <f:facet name="output">  
                                <h:outputText value="#{list.price}" />  
                            </f:facet>  
                            <f:facet name="input">  
                                <p:inputText value="#{list.price}" style="width:100%"/>  
                            </f:facet>  
                        </p:cellEditor>
                    </p:column>

                    <p:column headerText="Type" style="width:100px">
                        <p:cellEditor>  
                            <f:facet name="output">  
                                <h:selectOneMenu value="#{list.type}" disabled="true">  
                                    <f:selectItems value="#{mealManagerBean.dayOfWeek}" />                                    
                                </h:selectOneMenu>   
                            </f:facet>  
                            <f:facet name="input">  
                                <h:selectOneMenu value="#{list.type}" >  
                                    <f:selectItems value="#{mealManagerBean.dayOfWeek}" />   
                                    <p:ajax update="calendar1" />  
                                </h:selectOneMenu>  
                            </f:facet>  
                        </p:cellEditor>
                    </p:column>     

                    <p:column headerText="Specific Date" style="width:70px">  
                        <p:cellEditor>  
                            <f:facet name="output">  
                                <p:calendar value="#{list.specificDate}" disabled="true" style="width: 50px;"/>
                            </f:facet>  
                            <f:facet name="input">  
                                <p:calendar id="calendar1" value="#{list.specificDate}" disabled="#{list.type!=8}" style="width: 50px;"/>
                            </f:facet>  
                        </p:cellEditor>
                    </p:column>

                    <p:column headerText="Start Time" style="width:100px">
                        <p:cellEditor>  
                            <f:facet name="output">  
                                <h:selectOneMenu value="#{list.startTime}" disabled="true">  
                                    <f:selectItems value="#{mealManagerBean.timeOfDay}" />                                    
                                </h:selectOneMenu>   
                            </f:facet>  
                            <f:facet name="input">  
                                <h:selectOneMenu value="#{list.startTime}" >  
                                    <f:selectItems value="#{mealManagerBean.timeOfDay}" />   
                                </h:selectOneMenu>  
                            </f:facet>  
                        </p:cellEditor>
                    </p:column>  

                    <p:column headerText="End Time" style="width:100px">
                        <p:cellEditor>  
                            <f:facet name="output">  
                                <h:selectOneMenu value="#{list.endTime}" disabled="true">  
                                    <f:selectItems value="#{mealManagerBean.timeOfDay}" />                                    
                                </h:selectOneMenu>   
                            </f:facet>  
                            <f:facet name="input">  
                                <h:selectOneMenu value="#{list.endTime}" >  
                                    <f:selectItems value="#{mealManagerBean.timeOfDay}" />   
                                </h:selectOneMenu>  
                            </f:facet>  
                        </p:cellEditor>
                    </p:column>  

                    <p:column headerText="Options" style="width:50px" >  
                        <p:rowEditor/>  
                    </p:column>  
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Operation" />
                        </f:facet>
                        <p:commandButton value="Remove" update="formPriceControl" actionListener="#{mealManagerBean.removePriceControl(list.id)}" ajax="true">
                        </p:commandButton>
                    </p:column>

                </p:dataTable>
            </p:outputPanel>
        </h:form>
    </ui:define>
</ui:composition>